<?php
require '../requires.php';
session_start();

$cfg = array(
	'request_token_url' => 'http://www.example.com/framework/OAuth/Server/example/request_token.php',
	'authorize_url' => 'http://www.example.com/framework/OAuth/Server/example/authorize.php',
	'access_token_url' => 'http://www.example.com/framework/OAuth/Server/example/access_token.php',
	'api_url' => 'http://www.example.com/framework/OAuth/Server/example/api.php',
	'authorize_callback' => 'http://www.example.com/framework/OAuth/Client/example/callback.php',
	
	'host' => 'www.example.com',
	'format' => 'json',
	
	'consumer_key' => 'key',
	'consumer_secret' => 'secret',
);

$client = new FrameworkOAuthClient($cfg);

$oauth_verifier = $_GET['oauth_verifier'];
$oauth_token = $_GET['oauth_token'];

echo 'oauth_token: ', $oauth_token, '<br/>';
echo 'oauth_token_secret: ', $_SESSION['request_token_secret'], '<br/>';
if($oauth_verifier === '1') {
	$token = $client->getAccessToken($oauth_token, $_SESSION['request_token_secret']);
	if($token) {
		print_r($token);
		$_SESSION['access_token_key'] = $token['oauth_token'];
		$_SESSION['access_token_secret'] = $token['oauth_token_secret'];
		// clear request key and secret
		unset($_SESSION['request_token_key'], $_SESSION['request_token_secret']);
	}
}
?>
<a href="api.php">Test Api</a>